 <template>
  <div class="x-content">
    <el-row style="margin-bottom: 60px;">
      <el-col :span="24" class="x-title">竣工测绘基本信息</el-col>
      <el-col :span="4" class="x-other">
        <ul>
          <li>
            测绘单位：
            <span>{{form.auditAdviceBaseInfo.companyName}}</span>
          </li>
          <li>
            可整理规模：
            <span>{{form.auditAdviceBaseInfo.actualConsolidationScale}}</span>
          </li>
        </ul>
      </el-col>
      <el-col :span="4" class="x-other">
        <ul>
          <li>
            红线范围内总面积：
            <span>{{form.auditAdviceBaseInfo.totalAreaInRedline}}公顷</span>
          </li>
          <li>
            可复垦规模：
            <span>{{form.auditAdviceBaseInfo.actualReclamationScale}}公顷</span>
          </li>
        </ul>
      </el-col>
      <el-col :span="4" class="x-other">
        <ul>
          <li>
            可实施总规模：
            <span>{{form.auditAdviceBaseInfo.actualTotalScale}}公顷</span>
          </li>
          <li>
            新增耕地面积：
            <span>{{form.auditAdviceBaseInfo.newCultivatedLandArea}}公顷</span>
          </li>
        </ul>
      </el-col>
      <el-col :span="5" class="x-other">
        <ul>
          <li>
            可开发规模：
            <span>{{form.auditAdviceBaseInfo.actualDevelopmentScale}}公顷</span>
          </li>
          <li>
            1:10000土地利用现状图图幅号：
            <span>{{form.auditAdviceBaseInfo.drawingNumber}}</span>
          </li>
        </ul>
      </el-col>
    </el-row>
    <el-row style="margin-bottom: 60px;">
      <el-col :span="24" class="x-title">内业审查</el-col>
      <!-- 1 -->
      <!-- <el-col :span="24" class="x-subtitle">要件提交</el-col>
      <el-col :span="24" class="x-textarea">
        <el-input type="textarea" :rows="8" style="width:70%"></el-input>
      </el-col>-->
      <div>
        <el-col :span="24" class="x-subtitle">图件审查</el-col>
        <el-col :span="24" class="x-textarea">
          <el-input
            :readonly="disabled"
            type="textarea"
            v-model="form.drawingAudit"
            :rows="8"
            style="width:70%"
          ></el-input>
        </el-col>
      </div>
      <el-col :span="24" class="x-subtitle">数据及报告审查</el-col>
      <el-col :span="24" class="x-textarea">
        <el-input
          :readonly="disabled"
          type="textarea"
          v-model="form.dataReportAudit"
          :rows="8"
          style="width:70%"
        ></el-input>
      </el-col>
    </el-row>
    <el-row style="margin-bottom: 60px;">
      <el-col :span="24" class="x-title">外业审查</el-col>
      <!-- 1 -->
      <el-col :span="24" class="x-subtitle">其他草地审查</el-col>
      <el-col :span="24" class="x-textarea">
        <el-input
          :readonly="disabled"
          type="textarea"
          v-model="form.otherGrassAudit"
          :rows="8"
          style="width:70%"
        ></el-input>
      </el-col>
      <div>
        <el-col :span="24" class="x-subtitle">疑问审查</el-col>
        <el-col :span="24" class="x-textarea">
          <el-input
            :readonly="disabled"
            type="textarea"
            v-model="form.questionAudit"
            :rows="8"
            style="width:70%"
          ></el-input>
        </el-col>
      </div>
    </el-row>

    <el-row style="margin-bottom: 60px;">
      <el-col :span="24" class="x-title">市中心复审意见</el-col>
      <!-- 1 -->
      <el-row>
        <el-col :span="24" class="x-subtitle">经办人审查意见</el-col>
        <el-col :span="24" class="x-textarea">
          <el-input
            :readonly="disabled"
            type="textarea"
            :rows="8"
            style="width:70%"
            v-model="form.examineOpinion.opinion"
          ></el-input>
        </el-col>
        <el-col :span="24">
          <el-form label-width="90px" :inline="true">
            <el-form-item label="审查人">
              <img style="width: 100px;" :src="url" alt />
              <!-- <el-input  style="width:160px" size="small" v-model="form.examineOpinion.signature"></el-input> -->
            </el-form-item>
            <el-form-item label="审查日期">
              <el-date-picker
                :readonly="disabled"
                type="date"
                v-model="form.examineOpinion.createTime"
                size="small"
                style="width:160px"
              ></el-date-picker>
            </el-form-item>
            <el-form-item label="审查意见">
              <el-select
                :disabled="disabled"
                v-model="form.examineOpinion.status"
                size="small"
                style="width:160px"
              >
                <el-option value="0" label="同意"></el-option>
                <el-option value="1" label="拒绝"></el-option>
              </el-select>
            </el-form-item>
          </el-form>
        </el-col>
      </el-row>
      <!-- 2 -->
      <!-- <el-row>
        <el-col :span="24" class="x-subtitle">复核人审查意见</el-col>
        <el-col :span="24" class="x-textarea">
          <el-input type="textarea" :rows="8" style="width:70%"></el-input>
        </el-col>
        <el-col :span="24">
          <el-form label-width="90px" :inline="true">
            <el-form-item label="审查人">
              <el-input style="width:160px" size="small"></el-input>
            </el-form-item>
            <el-form-item label="审查日期">
              <el-date-picker type="date" size="small" style="width:160px"></el-date-picker>
            </el-form-item>
            <el-form-item label="审查意见">
              <el-select size="small" style="width:160px">
                <el-option value="1" label="同意"></el-option>
                <el-option value="2" label="拒绝"></el-option>
              </el-select>
            </el-form-item>
          </el-form>
        </el-col>
      </el-row>-->
    </el-row>
    <div class="btn">
      <el-button v-if="!disabled" type="primary" @click="onsubmit">提交</el-button>
      <el-button v-if="!disabled">取消</el-button>
      <el-button v-if="disabled" @click="back">返回</el-button>
    </div>
  </div>
</template>

<script>
import {
  getAdviceDatareview,
  getReviewOpinionsreview,
  saveOpinionsreview,
  saveAdviceData
} from "@/api/project1/completedMapping/countyrecheckOpinion";
import {
  getInvAndCon,
  getAdvice,
  addAdvice,
  getSignature
} from "@/api/feasibilityStudy/countyReviewOpinions.js";
import { getCheckData, insetYjData } from "@/api/common.js";
import config from "@/config/index.js";
import moment from "moment";
export default {
  name: "baseMessage",
  data() {
    return {
      projectId: localStorage.getItem("projectId"),
      form: {
        auditAdviceBaseInfo: {},
        examineOpinion: {
          projectId: localStorage.getItem("projectId"),
          groupId: 17,
          type: 0,
          opinion: "",
          signature: "",
          status: "0",
          createTime: ""
        },
        auditType: 1,
        drawingAudit: "",
        dataReportAudit: "",
        otherGrassAudit: "",
        questionAudit: "",
        projectId: localStorage.getItem("projectId")
      },
      url: "",
      baseUrl: config.baseUrlImg,
      disabled: true
    };
  },
  created() {
    if (this.$route.name === localStorage.getItem("key")) {
      this.disabled = false;
    }
    if (localStorage.getItem("lookStatus") == 2) {
      this.disabled = true;
    }
    this.getTime();

    this.getAdviceDatareview();
    this.getSignature();
  },
  methods: {
    back() {
      this.$router.push("/projectManagement/projectImplementation/dealwith");
    },
    getTime() {
      var date = new Date();
      var year = date.getFullYear();
      var month = date.getMonth() + 1;
      var day = date.getDate();
      if (month < 10) {
        month = "0" + month;
      }
      if (day < 10) {
        day = "0" + day;
      }
      var trueTime = year + "-" + month + "-" + day;

      this.form.examineOpinion.createTime = trueTime;
    },
    getAdviceDatareview() {
      getAdviceDatareview({
        projectId: this.projectId
      }).then(res => {
        if (res.data.auditAdviceBaseInfo) {
          this.form.auditAdviceBaseInfo = res.data.auditAdviceBaseInfo;
        }
        if (res.data.drawingAudit) {
          this.form.drawingAudit = res.data.drawingAudit;
        }
        if (res.data.dataReportAudit) {
          this.form.dataReportAudit = res.data.dataReportAudit;
        }
        if (res.data.otherGrassAudit) {
          this.form.otherGrassAudit = res.data.otherGrassAudit;
        }
        if (res.data.questionAudit) {
          this.form.questionAudit = res.data.questionAudit;
        }
        this.getCenterAdvicereview();
      });
    },
    getCenterAdvicereview() {
      getCheckData({
        groupId: 17,
        projectId: this.projectId,
        type: 0
      }).then(res => {
        console.log(res);
        if (res.data) {
          this.form.examineOpinion.opinion = res.data.opinion;
          this.form.examineOpinion.signature = res.data.signature;
          this.form.examineOpinion.status = String(res.data.status);
          this.form.examineOpinion.createTime = res.data.createTime.slice(
            0,
            10
          );
        }
      });
    },
    getSignature() {
      getSignature({}).then(res => {
        console.log(res.data);
        this.url = this.baseUrl + res.data;
        console.log(this.url);
      });
    },
    onsubmit() {
      const loading = this.$loading({
        lock: true,
        text: "Loading",
        spinner: "el-icon-loading",
        background: "rgba(0, 0, 0, 0.7)"
      });
      console.log(
        this.format(this.form.examineOpinion.createTime, "yyyy-MM-dd")
      );
      this.form.examineOpinion.createTime = this.format(
        this.form.examineOpinion.createTime,
        "yyyy-MM-dd HH:mm:dd"
      );
      this.form.examineOpinion.signature = this.url;
      console.log(this.form);
      saveOpinionsreview(this.form)
        .then(res => {
          loading.close();
          this.$message({
            message: "提交成功",
            type: "success"
          });
          this.$router.push(
            "/projectManagement/projectImplementation/dealwith"
          );
        })
        .catch(err => {
          loading.close();
        });
    },
    //转化时间
    format(time, format) {
      var t = new Date(time);
      var tf = function(i) {
        return (i < 10 ? "0" : "") + i;
      };
      return format.replace(/yyyy|MM|dd|HH|mm|ss/g, function(a) {
        switch (a) {
          case "yyyy":
            return tf(t.getFullYear());
            break;
          case "MM":
            return tf(t.getMonth() + 1);
            break;
          case "mm":
            return tf(t.getMinutes());
            break;
          case "dd":
            return tf(t.getDate());
            break;
          case "HH":
            return tf(t.getHours());
            break;
          case "ss":
            return tf(t.getSeconds());
            break;
        }
      });
    }
  }
};
</script>

<style scoped lang="scss">
.x-content {
  margin-top: 20px;
  background-color: #fff;
  padding: 20px;
  .x-title {
    font-size: 18px;
    font-family: PingFang SC;
    font-weight: bold;
    line-height: 25px;
    color: rgba(77, 77, 77, 1);
    margin-bottom: 30px;
  }
  .x-project {
    display: flex;
    align-items: center;
    font-size: 14px;
    font-family: PingFang SC;
    font-weight: 500;
    color: rgba(102, 102, 102, 1);
    margin-bottom: 20px;
    ul {
      display: flex;
      li {
        margin-right: 30px;
        font-size: 13px;
        font-family: PingFang SC;
        font-weight: 500;
        color: rgba(166, 166, 166, 1);
      }
    }
  }
  .x-other {
    font-size: 14px;
    font-family: PingFang SC;
    font-weight: 500;
    line-height: 20px;
    color: rgba(102, 102, 102, 1);
    margin-bottom: 20px;
    ul {
      li {
        margin-bottom: 20px;
        span {
          font-size: 14px;
          font-family: PingFang SC;
          font-weight: 500;
          line-height: 20px;
          color: rgba(166, 166, 166, 1);
        }
      }
    }
  }
  .x-total {
    span:first-child {
      font-size: 14px;
      font-family: PingFang SC;
      font-weight: bold;
      line-height: 20px;
      color: rgba(51, 51, 51, 1);
    }
    span:last-child {
      font-size: 14px;
      font-family: PingFang SC;
      font-weight: 500;
      line-height: 20px;
      color: rgba(51, 51, 51, 1);
    }
  }
  .x-subtitle {
    font-size: 14px;
    font-family: PingFang SC;
    font-weight: 500;
    line-height: 20px;
    color: rgba(102, 102, 102, 1);
    margin-bottom: 10px;
  }
  .x-textarea {
    margin-bottom: 20px;
  }
}
</style>